package com.service.consumer.factory;

import com.service.consumer.feign.RemoteProviderService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author 24466
 * @date 2024/10/13 15:19
 */
@Component
public class RemoteProviderFallbackFactory implements FallbackFactory<RemoteProviderService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteProviderFallbackFactory.class);
    @Override
    public RemoteProviderService create(Throwable throwable) {
        log.error("客户端调用失败:{}", throwable.getMessage());
        return new RemoteProviderService() {
            @Override
            public String echo(String str) {
                return "获取provider echo失败："+throwable.getMessage();
            }
        };
    }
}
